package com.terrace.core.mybatis.plugin.pagination.parser;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.mapping.BoundSql;
import org.apache.ibatis.mapping.MappedStatement;
import org.apache.ibatis.mapping.ParameterMapping;
import org.apache.ibatis.session.Configuration;

import com.terrace.core.mybatis.plugin.pagination.Constant;
import com.terrace.core.mybatis.entity.Pagination;

/**
 * 分页SQL解析接口
 * 
 * @author jiangyg
 *
 */
public interface Parser extends Constant {

	/**
	 * 获取分页统计SQL
	 * 
	 * @param sql
	 *            原SQL
	 * @return
	 */
	public String getCountSQL(String sql);

	/**
	 * 获取分页SQl
	 * 
	 * @param sql
	 *            原SQL
	 * @return
	 */
	public String getPaginationSQL(String sql);

	/**
	 * 获取分页参数映射
	 *
	 * @param configuration
	 * @param boundSql
	 * @return
	 */
	public List<ParameterMapping> getPageParameterMapping(Configuration configuration, BoundSql boundSql);

	/**
	 * 设置分页参数
	 *
	 * @param ms
	 * @param parameterObject
	 * @param boundSql
	 * @param page
	 * @return
	 */
	public Map<String, Object> setPageParameter(MappedStatement ms, Object parameterObject, BoundSql boundSql, Pagination<?> pagination);

}
